package com.usian.order.controller;

import com.usian.common.vo.ResultVo;
import com.usian.order.pojo.Order;
import com.usian.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 06 26 09 26
 **/
@RestController
@RequestMapping("/api/order")
@Slf4j
@RefreshScope
@CrossOrigin
public class OrderController {

    @Autowired
    OrderService orderService;



    @Value("${name}")
    String name;

   @RequestMapping("/findById/{id}")
   public Order findById(@PathVariable Integer id){
        return  orderService.findById(id);
    }


    @GetMapping("/testName")
    public String testName(){
       log.info("配置参数 name：{}",name);
       return "OK";
    }

    @GetMapping("/findAll")
    public ResultVo findAll(){
        List<Order> all = orderService.findAll();
        return ResultVo.ok(all);
    }

}
